package com.fuyun.microservice.codec.msg;

import com.fuyun.microservice.utils.BufferUtil;

import java.util.Arrays;


public class Message  {
    private static final long serialVersionUID = -4245789758843785127L;
    private Header header;
    private byte[] buffer=  new byte[0];

    public Message() {
        if (header == null) {
            header = new Header();

            header.setSequenceNo(BufferUtil.getSequenceNo());
        }

        setHeader(header);
    }


    public void setHeader(Header head) {
        this.header = head;
    }


    public Header getHeader() {
        return header;
    }


    public void setBodyBuffer(byte[] buffer) {
        this.buffer = buffer;
    }


    public byte[] getBodyBuffer() {
        return buffer;
    }

    @Override
    public String toString() {
        return "Message{" +
                "header=" + header.toString() +
                ", buffer=" + Arrays.toString(buffer) +
                '}';
    }
}
